package com.yq.retokhttp.http.api.manager;

import android.support.v4.util.ArrayMap;

import retrofit2.Retrofit;

/**
 * 接口管理器
 */
public class ServiceManager {
    private static final ArrayMap<Class, Object> mServiceMap = new ArrayMap<>();

    public static <T> T create(Class<T> serviceClass, Retrofit retrofit) {
        Object service = mServiceMap.get(serviceClass);
        if (service == null) {
            service = retrofit.create(serviceClass);
            mServiceMap.put(serviceClass, service);
        }
        return (T) service;
    }
}
